<template>
  <div class="outer">
    <el-input
      type="text"
      v-model="inpVal"
      placeholder="姓名"
      style="width: 200px"
    ></el-input>

    <span style="margin: 0 20px">创建时间:</span>
    <el-date-picker
      v-model="dateVal"
      type="datetimerange"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
      :default-time="['12:00:00']"
      style="width: 400px"
    >
    </el-date-picker>
    <el-button type="primary" icon="el-icon-search" style="margin: 0 20px" @click="searchUserHD"
      >查询</el-button
    >
    <el-button style="margin-bottom: 20px" @click="resetUserHD" >清空</el-button>


    <el-table v-loading='isLoading' :data="userInfoList" border style="width: 100%">
      <el-table-column type="index" label="序号" width="60"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="180">
      </el-table-column>
      <el-table-column prop="certificatesType" label="证件类型">
        <template v-slot='{row}'>
          <span>{{row.certificatesType==='10'?'身份证':row.certificatesType==='20'?'户口本':''}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="certificatesNo" label="证件号"> </el-table-column>
      <el-table-column prop="createTime" label="创建时间"> </el-table-column>
      <el-table-column prop="address" label="操作">
        <template v-slot="{ row }">
          <el-button type="success" @click="toShowHD(row)" size="small" >查看</el-button>
          <el-button size="small" :disabled="!$hasBP('btn.User.pass')" >通过</el-button>
          <el-button size="small" :disabled="!$hasBP('btn.User.fail')">不通过</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      style="margin-top:20px"
      :current-page.sync="page"
      :page-size.sync="limit"
      background
      layout="prev, pager, next, ->, sizes,total"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { reqUserShowHD } from "@/api/userInfo";
export default {
  name: "AuthList",
  data() {
    return {
      inpVal: "",
      dateVal: "",
      page: 1,
      limit: 10,
      total: 0,
      userInfoList: [],
      isLoading:false
    };
  },
  mounted() {
    // 初始化数据
    this.getUserInfoListHD();
    // console.log(this.$route.name);
  },
  methods: {
    // 1.获取会员分页数据
    async getUserInfoListHD() {
      this.isLoading = true
      try {
        const res = await reqUserShowHD(this.page,this.limit,this.inpVal,this.dateVal[0],this.dateVal[1]);
        // console.log('1111',res);
        this.total = res.data.total;
        this.userInfoList = res.data.records;

        this.isLoading = false
      } catch (error) {
        this.isLoading = false
      }
    },
    // 2.去查看
    toShowHD(row) {
      // console.log("row", row);
      this.$router.push({
        name: "Show",
        query: {
          id: row.id,
          form:this.$route.name
        },
      });
    },
    // 3.搜索功能
    searchUserHD(){
      // console.log(this.inpVal);
      // console.log(this.dateVal);

      this.getUserInfoListHD()
    },
    // 4.清空功能
    resetUserHD(){
      this.inpVal= "",
      this.dateVal= "",
      this.page=1,
      this.limit=10,
      this.getUserInfoListHD()
    },
  },
  watch: {
    pageList: {
      immediate: true,
      deep: true,
      handler() {
        this.getUserInfoListHD();
      },
    },
  },
  computed: {
    pageList() {
      return { page: this.page, limit: this.limit };
    },
    
  },
};
</script>

<style scoped>
.outer {
  padding: 24px;
}
</style>
